package com.system.jfm.Components;

import com.system.tools.Range;
import javax.swing.*;
import java.awt.*;
import java.awt.font.NumericShaper;

public class RangeInputPanel extends JPanel{

    JTextField min;
    JTextField max;

    JLabel toLabel;

    public RangeInputPanel(){

        max = new JTextField();
        toLabel = new JLabel("TO");
        min = new JTextField();

        min.setPreferredSize(new Dimension(80, 30));
        max.setPreferredSize(new Dimension(80, 30));
//        max.setSize(30,100);

        this.add(min,BorderLayout.WEST);
        this.add(toLabel);
        this.add(max,BorderLayout.EAST);


    }

    public Range getRange(){

        String min_str =  this.min.getText();
        String max_str =  this.max.getText();

        double max_num;
        double min_num;

        if(min_str.equals("")){
            min_num = -9999;
        }else{
            min_num =  Double.parseDouble(min_str);
        }

        if(max_str.equals("")){
            max_num = 9999;
        }else{
            max_num =  Double.parseDouble(max_str);
        }

        return new Range(min_num,max_num);

    }

}
